<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity5">
<head>


    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title></title>
    <link rel="stylesheet" th:href="@{/css/bootstrap.min.css}">
    <script th:src="@{/js/jquery-2.1.4.min.js}"></script>
    <script th:src="@{/js/bootstrap.min.js}"></script>
    <!-- CSRF -->
<!--    <meta name="_csrf" th:content="${_csrf.token}"/>
    &lt;!&ndash; default header name is X-CSRF-TOKEN &ndash;&gt;
    <meta name="_csrf_header" th:content="${_csrf.headerName}"/>-->
</head>
<body>
<h1>您的订单正在创建，请稍后...</h1>
<input type="hidden" id="productId" th:value="${productId}">
<script>
    $(function () {
        var productId = $("#productId").val();
        if(productId) {
            var timer = setInterval(function () {
                $.ajax({
                    url:'/order/waitingSeckillOrderCreated/'+productId,
                    dataType:'json',
                    success:function (result) {
                        if(result.code==200) {
                            clearInterval(timer);
                            alert('订单创建成功，请及时支付订单');
                            location.href='/pay/?order_id=' + result.data;
                        } else {
                            console.log(result);
                        }
                    },
                    error:function (xhr) {
                        console.log(xhr);
                    }
                })
            },1000);
            //二分钟后取消查询
            setTimeout(function () {
                clearInterval(timer);
            },120000);
        }
    })
</script>
</body>
</html>